/**
 * 
 */
package org.hotpotmaterial.codegenn2.config;

import java.util.ArrayList;
import java.util.List;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.Parameter;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author cakydeveloper
 *
 */
@Configuration
@EnableSwagger2
public class SwaggerConfiguration {

	ApiInfo apiInfo() {
		return new ApiInfoBuilder().title("HM-CodeGen-N2 API").description("HotpotMaterial团队N2版代码生成器")
				.license("Apache 2.0").licenseUrl("http://unlicense.org").termsOfServiceUrl("").version("1.0.0")
				.contact(new Contact("wenxing", "https://gitee.com/xwxsee/HM-CodeGenN2", "xwxsee@126.com")).build();
	}

	@Bean
	public Docket customImplementation() {
		// 添加header参数
		ParameterBuilder ticketPar = new ParameterBuilder();
		List<Parameter> pars = new ArrayList<>();
		pars.add(ticketPar.name("AUTH_TOKEN").description("AUTH_TOKEN").modelRef(new ModelRef("string"))
				.parameterType("header").required(false).build());

		return new Docket(DocumentationType.SWAGGER_2).select()
				.apis(RequestHandlerSelectors.basePackage("org.hotpotmaterial.codegenn2.controller")).build()
				.globalOperationParameters(pars).apiInfo(apiInfo());
	}

}
